<template>
    <!-- 发货信息，用于导出代发货订单的excel交给快递公司 -->
    <el-dialog :close-on-click-modal="false"
               :modal="false"
               :visible.sync="visible"
               title="请输入发货信息"
               width="38%">
        <el-form :model="dataForm"
                 :rules="dataRule"
                 @keyup.enter.native="dataFormSubmit()"
                 label-width="120px"
                 ref="dataForm">
            <el-form-item label="发件人姓名"
                          prop="consignmentName">
                <el-input controls-position="right"
                          label="发件人姓名"
                          v-model="dataForm.consignmentName"></el-input>
            </el-form-item>
            <el-form-item label="发货人手机号"
                          prop="consignmentMobile">
                <el-input controls-position="right"
                          label="发货人手机号"
                          v-model="dataForm.consignmentMobile"></el-input>
            </el-form-item>
            <el-form-item label="发货地址"
                          prop="consignmentAddr">
                <el-input controls-position="right"
                          label="发货地址"
                          v-model="dataForm.consignmentAddr"></el-input>
            </el-form-item>
        </el-form>
        <span class="dialog-footer"
              slot="footer">
      <el-button @click="visible = false" size="small">取消</el-button>
      <el-button @click="dataFormSubmit()" size="small"
                 type="primary">确定</el-button>
    </span>
    </el-dialog>
</template>
<script>
    export default {
        data() {
            return {
                visible: false,
                dataForm: {
                    consignmentName: '',
                    consignmentMobile: '',
                    consignmentAddr: ''
                },
                dataRule: {
                    consignmentName: [
                        {required: true, message: '不能为空', trigger: 'blur'}
                    ],
                    consignmentMobile: [
                        {required: true, message: '不能为空', trigger: 'blur'}
                    ],
                    consignmentAddr: [
                        {required: true, message: '不能为空', trigger: 'blur'}
                    ]
                }
            }
        },
        methods: {
            init(orderNumber, dvyId, dvyFlowId) {
                this.visible = true
                this.$nextTick(() => {
                    this.$refs['dataForm'].resetFields()
                })
            },
            // 表单提交
            dataFormSubmit() {
                this.$refs['dataForm'].validate((valid) => {
                    if (valid) {
                        this.visible = false
                        this.$emit('inputCallback', this.dataForm)
                    }
                })
            }
        }
    }
</script>
